<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-09-29
 * Time: 13:48
 */

namespace backend\controllers;


use app\models\CtiFile;
use app\models\CtiJnz;
use app\models\search\CtiCdrSearch;
use app\models\search\CtiJnzSearch;
use common\helps\Tools;
use common\helps\UploadFiles;
use yii\helpers\ArrayHelper;

class CtiManagerJnzController  extends CtiManagerController
{

    /**
     * 技能组的列表
     */
    public function actionList()
    {
        return $this->getList(new CtiJnz());
    }
    /**
     * 查询
     */
    public function actionFind($id)
    {
        $res = ArrayHelper::toArray(CtiJnzSearch::findOne($id));
        return json_encode($res);
    }

    /**
     * 保存数据
     */
    public function actionSave(){
        $data = $_POST['data'];
        $jnz = new CtiJnz();
        if (empty($data['CtiJnz']['id'])){
            $jnz->load($data);
            $res = $jnz->save();
            if ($res){
                return 1;
            }else{
                return 0;
            }
        }else{
            $jnz = $jnz::findOne($data['CtiJnz']['id']);
            $res = $jnz->updateAttributes($data['CtiJnz']);
            if ($res){
                return 2;
            }else{
                return 3;
            }
        }
    }
    /**
     * 删除
     */
    public function actionDelete(){
        $id = $_GET['id'];
        $model = CtiJnz::findOne($id);
        $res = $model->delete();
        return $res;
    }


}